package com.gexin.service.index;

import com.gexin.model.config.Banner;
import com.gexin.model.notice.NoticeNews;
import com.gexin.model.notice.NoticePlacard;
import com.gexin.service.notice.NoticeNewsService;
import com.gexin.service.product.ProductService;
import com.jfinal.plugin.activerecord.Page;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class XappIndexService {
	public static XappIndexService dao = new XappIndexService();

	public Map<String, Object> findIndex() {

//		展示banner、扫码、产品分类、产品首页推荐、预售产品首页推荐、资讯首页推荐、平台公告首页推荐等。
		Map<String,Object> map = new HashMap<>();
		//banner轮播图  获取所有已生效的
		List<Banner> list = Banner.dao.getList(Banner.STATEEFFECT);
		map.put("banner",list);
		//咨询
		Page<NoticeNews> indexNoticeList = NoticeNewsService.dao.findIndexList();
		map.put("indexNoticeList",indexNoticeList);
		//公告
		NoticePlacard noticePlacard = new NoticePlacard();
		noticePlacard.setState(NoticePlacard.STATEEFFECT);
		Page<NoticePlacard> noticePlacardPage = NoticePlacard.dao.query(1 , 5 , noticePlacard);
		map.put("noticePlacardPage",noticePlacardPage);
		//热卖普通商品
		map.put("hotProduct",ProductService.dao.findByHotProduct(1));
		//热卖预售商品
		map.put("preProduct",ProductService.dao.findByHotProduct(2));
		return map;
	}
}
